package com.huluobo.a2208parkdemo.notice

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.huluobo.a2208parkdemo.R
import com.huluobo.a2208parkdemo.databinding.ActivityNoticeBinding
import com.huluobo.base.mvvm.BaseActivity
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

@AndroidEntryPoint
class NoticeActivity : BaseActivity<ActivityNoticeBinding, NoticeViewModel>() {
    private lateinit var noticePagingAdapter: NoticePagingAdapter
    override fun initData() {
    }

    override fun initView() {
        binding.noticeHeader.headerTitle.text = "公告"
        binding.noticeHeader.headerBack.setOnClickListener { finish() }

        binding.noticeRv.layoutManager = LinearLayoutManager(this)
        noticePagingAdapter = NoticePagingAdapter()
        binding.noticeRv.adapter = noticePagingAdapter

        lifecycleScope.launch {
            vm.getNewsPagingData().collect {
                noticePagingAdapter.submitData(it)
            }
        }

    }
}